package map;

import java.util.HashMap;
import java.util.Map;

public class MapDemo2 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("语文",98);
        map.put("数学",87);
        map.put("英语",79);
        map.put("物理",91);
        map.put("历史",80);
        System.out.println(map);

        Integer value = map.get("语文");
        System.out.println(value);
        value = map.get("体育");
        System.out.println(value);
        System.out.println("大小："+map.size());
        System.out.println("是否为空集："+map.isEmpty());
        System.out.println("是否包含数学键："+map.containsKey("数学"));
        System.out.println("是否包含97值："+map.containsValue(97));

        map.remove("物理");
        System.out.println(map);

        value = map.remove("数学");
        System.out.println(value);
        System.out.println(map);

        map.clear();
        System.out.println(map);
    }
}
